<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-30 20:02:30
 * @LastEditTime: 2020-03-13 17:49:07
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="css/vant.css">
    <link rel="stylesheet" type="text/css" href="css/base.css" />
    <script type="text/javascript" src="script/jquery.js"></script>
    <script type="text/javascript" src="script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="script/vue.min.js"></script>
    <script src="script/vant.min.js"></script>
    <script type="text/javascript" src="script/fastclick.js"></script>
    <script type="text/javascript" src="script/base.js"></script>
    <style type="text/css">
        body {
            font: 600 16px/18px;
            color: #6a6f8c;
            background: url(image/login-bg.png) no-repeat;
            background-size: 100% 100%;
        }

        .login-content {
            padding: 80px 40px 20px 40px;
            width: 100%;
        }

        .login-logo {
            vertical-align: middle;
            padding-bottom: 5px;
        }

        .login-logo img {
            width: 70px;
            margin-right: 22px;
        }

        .app-name {
            border-bottom: 3px solid #cd1b21;
            display: inline-block;
            padding: 5px 0;
            font-size: 22px;
            font-weight: bolder;
            letter-spacing: 2px;
        }

        .login-group {
            margin-bottom: 15px;
            overflow: hidden;
        }

        .login-label {
            color: #aaa;
            font-size: 16px;
            letter-spacing: 4px;
            padding-bottom: 8px;
        }

        .login-input {
            border: none;
            padding: 15px 20px;
            border-radius: 5px;
            background: rgba(0, 0, 0, 0.1);
            width: 100%;
            color: #3a3a3a;
            display: block;
            outline: none;
        }


        .hr {
            height: 2px;
            margin: 0 0 20px 0;
            background: rgba(255, 255, 255, .2);
        }

        .foot-lnk {
            text-align: center;
        }

        .foot-lnk img {
            width: 14px;
            margin-right: 10px;
            vertical-align: sub;
        }

        .foot-lnk a {
            color: inherit;
            text-decoration: none;
            font-size: 12px;
        }

        .van-checkbox__icon .van-icon {
            background: rgba(0, 0, 0, 0.1);
        }

        .arrow {
            position: absolute;
            right: 14px;
            top: 16px;
        }

        .back {
            position: absolute;
            top: 20px;
            left: 10px;
            font-size: 18px;
            padding: 10px;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="login-content" v-cloak>
            <div style="padding: 0 0 35px;text-align: center;">
                <span class="login-logo">
                    <img src="image/head_logo.png" />
                    <img src="image/head_text.png" style="width: 138px;margin:0;" />
                </span>
            </div>
            <div>
                <div class="login-group">
                    <div class="login-label">登录账户</div>
                    <div>
                        <input type="text" class="login-input" v-model="formData.phone" />
                    </div>
                </div>
                <div class="login-group">
                    <div class="login-label">登录密码</div>
                    <div>
                        <input type="password" class="login-input" v-model="formData.pwd" />
                    </div>
                </div>
                <div class="login-group">
                    <!-- <div style="float: left;">
                        <van-checkbox v-model="isRemb" shape="square" checked-color="#cd1b21">
                            <span style="color:#aaa">记住密码</span>
                        </van-checkbox>
                    </div> -->
                    <div style="float: left;color:#cd1b21;" @click="forgetPassword">忘记密码?</div>
                    <div style="float: right;color:#ff976a;" @click="register">注册</div>
                </div>
                <div class="login-group">
                    <van-button :disabled="ifConfirm" :loading="ifConfirm" loading-text="登录中..." type="primary" block
                        @click="loginAPP">登&nbsp;&nbsp;&nbsp;&nbsp;录</van-button>
                </div>
            </div>
        </div>

        <div class="back" @click="onClickLeft">
            <van-icon name="arrow-left"></van-icon>
        </div>

    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        //$('.init-full').show();

        var map = api.require('bMap');
        if (api.systemType == 'ios') {
            map.initMapSDK(function (ret) { });
        }

        map.getLocation({
            accuracy: '10m',
            autoStop: true
        }, function (ret, err) {

        })



        api.addEventListener({
            name: 'clearLoginInfo'
        }, function (ret, err) {
            vm.formData.phone = '';
            vm.formData.pwd = '';
            // vm.isRemb = false;
        })

        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                showRole: false,
                formData: {
                    phone: '',
                    pwd: ''
                },
                // isRemb: false,
                ifConfirm: false
            },
            created: function () {
                if (FLD.getUserInfo()) {
                    // if (FLD.getUserInfo().isRemb) {
                    //     window.localStorage.setItem('systemType', api.systemType);
                    //     api.openWin({
                    //         name: '主页',
                    //         url: 'html/base.html',
                    //         reload: true,
                    //         slidBackEnabled: false
                    //     })
                    // } else {
                    //     this.formData.phone = FLD.getUserInfo().UserCode;
                    // }
                    this.formData.phone = FLD.getUserInfo().UserCode;
                }
            },
            methods: {
                register() {
                    api.openWin({
                        name: '注册',
                        url: 'register.html',
                        reload: true,
                        slidBackEnabled: false
                    })
                },
                forgetPassword() {
                    api.openWin({
                        name: '忘记密码',
                        url: 'forgetPassword.html',
                        reload: true,
                        slidBackEnabled: false
                    })
                },
                loginAPP() {
                    var that = this;
                    // api.openWin({
                    //     name: '完善信息',
                    //     url: 'html/informationPerfection.html',
                    //     reload: true,
                    //     slidBackEnabled: false,
                    //     pageParam: {
                    //         id: 1
                    //     }
                    // })
                    // return
                    if (!that.formData.phone) {
                        layer.open({
                            content: '请填写登录账户',
                            skin: 'msg',
                            time: 2
                        });
                        return false;
                    }
                    if (!that.formData.pwd) {
                        layer.open({
                            content: '请填写登录密码',
                            skin: 'msg',
                            time: 2
                        });
                        return false;
                    }
                    that.ifConfirm = true;
                    FLD.shoppingMallAjax('LoginUser', that.formData, function (res) {
                        that.ifConfirm = false;
                        window.localStorage.setItem('systemType', api.systemType);
                        var data = JSON.parse(res);
                        if (data.status == 200) {
                            window.localStorage.setItem('userInfo', JSON.stringify(data.data.Table[0]));
                            api.sendEvent({
                                name: 'refreshAboutUser'
                            });
                            api.closeWin();

                        } else {
                            // alert(JSON.stringify(data))
                            if (data.status == 400) {     //未完善
                                api.openWin({
                                    name: '完善信息',
                                    url: 'html/informationPerfection.html',
                                    reload: true,
                                    slidBackEnabled: false,
                                    pageParam: {
                                        id: data.data.Table[0].UserId,
                                        form: 'login'
                                    }
                                })
                            } else if (data.status == 600) {      //审核失败
                                that.$dialog.confirm({
                                    title: '提示',
                                    message: '您提交的企业信息未通过审核,是否重新前往完善?'
                                }).then(() => {
                                    api.openWin({
                                        name: '完善信息',
                                        url: 'html/informationPerfection.html',
                                        reload: true,
                                        slidBackEnabled: false,
                                        pageParam: {
                                            userInfo: data.data.Table[0],
                                            form: 'login'
                                        }
                                    })
                                }).catch(() => {

                                });
                            } else {
                                layer.open({
                                    content: data.msg,
                                    skin: 'msg',
                                    time: 2
                                });
                            }
                        }
                    })


                },
                onClickLeft() {
                    api.closeWin();

                }
            }
        })
    };
</script>

</html>